package com.example.entity.Page;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * @author: tobed
 * @date: 2022/11/10
 * @time: 8:56
 */
public class MyPageHelper {
    /**
     * 设置分页参数
     * @param pageRequest
     */
    public static void startPage(PageRequest pageRequest){
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
    }

    /**
     * 封装 pageInfo
     * @param content
     * @return
     */
    public static PageResult getPageResult(List content){
        PageInfo pageInfo = new PageInfo(content);
        PageResult pageResult = new PageResult();
        pageResult.setTotal(pageInfo.getTotal());
        pageResult.setContent(pageInfo.getList());
        pageResult.setPages(pageInfo.getPages());
        pageResult.setPageSize(pageInfo.getPageSize());
        pageResult.setPageNum(pageInfo.getPageNum());
        return pageResult;
    }
}
